/**
 * Copyright (c) 2007 Digital Primates IT Consulting Group
 * 
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
 * files (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use,
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following
 * conditions:
 * 
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 **/ 
package net.digitalprimates.flex2.unit.sequence {
	/** 
	 * The SequencerCheckerClass is used by the TestCase sequence code to indicate
	 * that sequence has ended and a method should now be called to make any assertions
	 * and resolve the test. 
	 */
	public class SequenceChecker implements ISequenceVerify {
        /**
         * @private
         */
		protected var _passThroughData:Object;

        /**
         * @private
         */
		protected var _eventHandler:Function;

		/** 
		 * A generic object that is optionally provided by the developer when 
		 * starting a new asynchronous operation.
		 * 
		 * This generic object is passed to the eventHandler function if it is 
		 * called. 
		 */
		public function get passThroughData():Object {
			return _passThroughData;
		}

		/** 
		 * <p>
		 * A reference to the event handler that should be called if the event 
		 * named in the previous sequence action fires before the timeout is 
		 * reached. </p>
		 * 
		 * <p>
		 * The handler is expected to have the follow signature:</p>
		 * 
		 * <p><code>
		 * public function handleEvent( event:Event, passThroughData:Object ):void {
		 * }</code></p>
		 * 
		 * <p>
		 * The first parameter is the original event object.
		 * The second parameter is a generic object that can optionally be provided 
		 * by the developer when creating a new sequence.
		 **/
		public function get eventHandler():Function {
			return _eventHandler;
		}
		
		/** 
		 * Constructor.
		 * 
		 * @param eventHandler Reference to the event handler to be called if previous sequence action fires before timeout is reached.
		 * @param passThroughData Parameter provided when starting new async operation.
		 */
		public function SequenceChecker( eventHandler:Function, passThroughData:Object=null  ) {
			_passThroughData = passThroughData;
			_eventHandler = eventHandler;
		}
	}
}